package com.maduar.batch.job;

import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.job.flow.FlowExecutionStatus;
import org.springframework.batch.core.job.flow.JobExecutionDecider;

import static com.maduar.batch.constant.JobConstant.EVEN;
import static com.maduar.batch.constant.JobConstant.ODD;

/**
 * Description:
 *
 * @author maduar maduar@163.com
 * @date 2021-07-10 14:24
 */
public class MyDecider implements JobExecutionDecider {

    private int count;

    @Override
    public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) {
        count++;
        if (count % 2 == 0) {
            return new FlowExecutionStatus(EVEN);
        } else {
            return new FlowExecutionStatus(ODD);
        }
    }
}
